/**
 * amis v6.13.0
 * build time: 2025-08-12
 * Copyright 2018-2025 baidu
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var mobxReact = require('mobx-react');
var React = require('react');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;


;function ItemActionsWrapper(props) {
  var _a;
  var cx = props.classnames;
  var children = props.children;
  var store = props.store;
  var divRef = React.useRef(null);
  var updatePosition = React__default["default"].useCallback(function (id) {
    var _a, _b;
    if (id === void 0) {
      id = ((_a = store.hoverRow) === null || _a === void 0 ? void 0 : _a.id) || '';
    }
    var frame = (_b = divRef.current.parentElement) === null || _b === void 0 ? void 0 : _b.querySelector('table');
    var dom = frame === null || frame === void 0 ? void 0 : frame.querySelector("tr[data-id=\"".concat(id, "\"]"));
    if (!dom) {
      return;
    }
    var rect = dom.getBoundingClientRect();
    var height = rect.height;
    var top = rect.top - frame.getBoundingClientRect().top + parseInt(getComputedStyle(frame)['marginTop'], 10);
    divRef.current.style.cssText += "top: ".concat(top, "px;height: ").concat(height, "px; left: ").concat(frame.parentElement.scrollLeft, "px;");
  }, []);
  React.useEffect(function () {
    var row = store.hoverRow;
    if (!row) {
      return;
    }
    updatePosition(row.id);
  }, [(_a = store.hoverRow) === null || _a === void 0 ? void 0 : _a.id]);
  React.useEffect(function () {
    var frame = divRef.current.parentElement;
    if (!frame) {
      return;
    }
    var onScroll = function () {
      var _a;
      updatePosition((_a = store.hoverRow) === null || _a === void 0 ? void 0 : _a.id);
    };
    frame.addEventListener('scroll', onScroll);
    return function () {
      frame.removeEventListener('scroll', onScroll);
    };
  });
  return _J$X_("div", {
    className: cx('Table-itemActions-wrap'),
    ref: divRef
  }, children);
}
var ItemActionsWrapper$1 = mobxReact.observer(ItemActionsWrapper);

exports["default"] = ItemActionsWrapper$1;
